# encoding: utf-8
# project: deep_learning
# file: pooling_2d.py
# time: 2024-12-13 14:13
# author: abcuqe
# license: copyright@ 2002-2024
# contact: abcque@outlook.com
# IDE: PyCharm
# description: 
import os
import tensorflow as tf
from keras.layers import MaxPooling2D, GlobalMaxPooling2D, GlobalAveragePooling2D, AveragePooling2D

if __name__ == '__main__':
    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

    x = tf.random.normal((1, 10, 10, 1))
    # 参数的默认值 pool_size=(2, 2)， strides = 2
    # pooling = MaxPooling2D()
    # y = pooling(x)
    # 
    # print(y.shape)
    # print(x)
    # print(y)

    # pooling = MaxPooling2D(strides=1)
    # y = pooling(x)
    # print(y.shape)

    # pooling = MaxPooling2D(strides=(3,2))
    # y = pooling(x)
    # print(y.shape)

    # pooling = MaxPooling2D(pool_size=(3,2))
    # y = pooling(x)
    # print(y.shape)

    # pooling = MaxPooling2D(pool_size=(1,2))
    # y = pooling(x)
    # print(y.shape)

    # size = (1, 2)
    # # 如果不指定 strides，其值为 pool_size
    # pooling = MaxPooling2D(pool_size=size,strides=size )
    # y = pooling(x)
    # print(y.shape)

    # 全局最大值池化
    # pooling = GlobalMaxPooling2D()
    # y = pooling(x)
    # print(y.shape)

    # pooling = GlobalAveragePooling2D()
    # y = pooling(x)
    # print(y.shape)

    pooling = AveragePooling2D()
    y = pooling(x)
    print(y.shape)





    
    
